function PublishControl(){}

PublishControl.prototype = new GControl();

PublishControl.prototype.initialize = function(map) {

 var container = document.createElement("div");

 var publishDiv = document.createElement("div");
 this.setButtonStyle_(publishDiv);
 publishDiv.appendChild(document.createTextNode("PUBLICAR"));
 GEvent.addDomListener(publishDiv,"click",publishFunction);

 container.appendChild(publishDiv);
 map.getContainer().appendChild(container);
 return container;

 function publishFunction(){

  map.clearOverlays();
  var marker = new GMarker(map.getCenter(), {draggable:true});
  
  function getInstructions(){
   var markerPoint=marker.getPoint();
   var instructionsHTML="<div style='font-style:italic;font-size:small'>";
    instructionsHTML+="PASO 1: Coloca la marca donde quieres publicar.<br><hr>";
    instructionsHTML+="<table style='font-style:italic;font-size:small'>";
    instructionsHTML+="<tr><td><img src='/img/moveControl.png'><br>Mueve el mapa</td>";          
    instructionsHTML+="<td><img src='/img/zoomControl.png'><br>ZoomIn/ZoomOut</td></tr>";
    instructionsHTML+="<tr><td colspan='2'><img src='/img/mark.png'/>";
    instructionsHTML+="<br>Arrastra la marca roja hasta tu lugar.</td></tr>";
    instructionsHTML+="<tr><td colspan='2'>(estos controles se encuentran en tu mapa)</td></tr>";
    instructionsHTML+="</table>";
    instructionsHTML+="<hr>";
    instructionsHTML+="Cuando tengas marcado tu lugar pasa a Ingresar Datos.";
    instructionsHTML+="<hr>";
    instructionsHTML+="<form action='enter_data.php' method='post'>";
    instructionsHTML+="<input type='hidden' name='latField' value='"+markerPoint.lat().toString()+"'>";
    instructionsHTML+="<input type='hidden' name='lngField' value='"+markerPoint.lng().toString()+"'>";
    instructionsHTML+="<input type='submit' value='Ingresar Datos'/>";
    instructionsHTML+="</form>";
    instructionsHTML+="<a href=''>- Cancelar Proceso de Registro -</a>";
   instructionsHTML+="</div>";
   return instructionsHTML;
  }

  map.addOverlay(marker);
  marker.openInfoWindowHtml(getInstructions());
  
  GEvent.addListener(marker, "dragstart", function() {map.closeInfoWindow();});
  GEvent.addListener(marker, "dragend", function() {marker.openInfoWindowHtml(getInstructions());});
  
 }//publishFunction

}//initialize

PublishControl.prototype.getDefaultPosition = function() {
 return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(615, 8));
}

PublishControl.prototype.setButtonStyle_ = function(button) {
 button.style.color = "green" /*"#0000cc"*/;
 button.style.backgroundColor = "white";
 button.style.font = "small Arial";
 button.style.border = "1px solid black";
 button.style.padding = "2px";
 button.style.marginBottom = "3px";
 button.style.textAlign = "center";
 button.style.width = "6em";
 button.style.cursor = "pointer";
}
